import time

# 方法1
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.switch_to import SwitchTo

# 引入wait和EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException, TimeoutException

wd = webdriver.Chrome(service=Service(".\chromedriver_win136.exe"))

wd.get("https://demo.automationtesting.in/Static.html")
try:
    ele = WebDriverWait(wd, 4).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "#angular123"))
    )
    print(ele.get_attribute("outerHTML"))  # 打印元素的文本内容
    print("目标出现，继续执行")
except TimeoutException as e:
    print("目标元素未出现")
